/// @tags: StirlingNumber
#include <cstdio>
#include <iostream>

using namespace std;

namespace BlueQuantum {

typedef long long LL;

int const N = 1e3 + 5;

int a[N], b[N], S[N][N];

inline LL qpow(LL base, int exp, int p) {
  LL res = 1;
  for (; exp; exp >>= 1, base = base * base % p)
    if (exp & 1) res = res * base % p;
  return res;
}

inline int main() {
  int n, x, p, m;
  cin >> n >> x >> p >> m;
  for (int i = 0; i <= m; ++i) cin >> a[i];
  S[0][0] = 1;
  for (int i = 1; i <= m; ++i) {
    for (int j = 1; j <= i; ++j) {
      S[i][j] = S[i - 1][j - 1] + (LL)S[i - 1][j] * j % p;
      if (S[i][j] >= p) S[i][j] -= p;
    }
  }
  for (int i = 0; i <= m; ++i) {
    for (int j = i; j <= m; ++j) {
      b[i] += (LL)S[j][i] * a[j] % p;
      if (b[i] >= p) b[i] -= p;
    }
  }
  LL fac = 1, ans = 0, revfac = 1;
  for (int i = 0; i <= m; ++i) {
    ans += b[i] * fac % p * revfac % p * qpow((x + 1) % p, n - i, p) % p;
    if (ans >= p) ans -= p;
    fac = fac * x % p, revfac = revfac * (n - i) % p;
  }
  cout << ans;
  return 0;
}

}  // namespace BlueQuantum

int main() {
#ifndef ONLINE_JUDGE
#ifdef LOCAL
  freopen("/tmp/CodeTmp/testdata.in", "r", stdin);
  freopen("/tmp/CodeTmp/testdata.out", "w", stdout);
#else
  freopen("P6620 [省选联考 2020 A 卷] 组合数问题.in", "r", stdin);
  freopen("P6620 [省选联考 2020 A 卷] 组合数问题.out", "w", stdout);
#endif
#endif

  ios::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
  return BlueQuantum::main();
}
